package cn.tedu.file;

import java.io.*;

/**
 * @author :Colin
 * @version 创建时间: 2021/6/17 14:13
 */
public class TestIn2 {
    public static void main(String[] args) {
        //method();
       method2();
    }

    private static void method2() {
        Reader in =null;
        try{
            in = new BufferedReader(new FileReader("D:\\PUNK\\5.TXT"));
            int b;
            while((b=in.read())!=-1){
                System.out.println(b);
            }
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method() {
        //Reader in =new Reader();//报错，抽象父级不能实例化
        //1.创建流对象
        //2.使用流对象
        //3.关流
        Reader fl=null;
        try {
             fl=new FileReader("D:\\PUNK\\1.TXT");
             int b;
             while((b=fl.read())!=-1){
                 System.out.println(b);
             }

        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                fl.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
